fix(git): recover interrupted initial sync#80
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces logic to safely handle Git synchronization in unborn repositories and clean up stale .git/HEAD.lock files left by interrupted operations. It adds helper methods hasInitialCommit and removeStaleHEADLock to GitLoader, skips stash and reset operations when no initial commit exists, and adds corresponding unit tests. Feedback on the changes includes a critical test assertion bug in datasource_git_test.go where an index mismatch (bbs[7] instead of bbs[8]) will cause test failures, and a potential TOCTOU race condition in removeStaleHEADLock where os.Remove could fail if the lock file is deleted by another process between the Lstat check and the deletion.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
2cc0388 to
6de66e2
Compare
6de66e2 to
804ca70
Compare
Handle unborn repositories and clean up stale HEAD locks before the initial pull.
Add local end-to-end coverage for both recovery paths.
Fixes errors seen during sync:
You do not have the initial commit yeterror: pathspec 'HEAD' did not match any file(s) known to gitcannot lock ref 'HEAD': reference already exists